﻿using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.WebAPI.Application.Command.UnitCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.UnitCommandHandler
{
    public class UnitAreaCommandHandler : IRequestHandler<UnitAreaCommand, Results<List<Area>>>
    {

        private readonly IUnitService unitService;
        private readonly ILogger<UnitAreaCommandHandler> logger;
        public UnitAreaCommandHandler(IUnitService unitService, ILogger<UnitAreaCommandHandler> logger)
        {
            this.unitService = unitService;
            this.logger = logger;
        }

        /// <summary>
        /// 区域列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<List<Area>>> Handle(UnitAreaCommand request, CancellationToken cancellationToken)
        {
            var userInfo = await unitService.UnitList
               (request.CityId);
            return Results<List<Area>>.DataResult(userInfo);
        }





    }


}
